/*
 ***************************************************************************
 * MediaTeK Inc.
 * 4F, No. 2 Technology	5th	Rd.
 * Science-based Industrial	Park
 * Hsin-chu, Taiwan, R.O.C.
 *
 * (c) Copyright 2002-2012, MTK.
 *
 * All rights reserved.	MediaTeK's source	code is	an unpublished work	and	the
 * use of a	copyright notice does not imply	otherwise. This	source code
 * contains	confidential trade secret material of MediaTeK Tech. Any attemp
 * or participation	in deciphering,	decoding, reverse engineering or in	any
 * way altering	the	source code	is stricitly prohibited, unless	the	prior
 * written consent of MediaTeK, Inc. is obtained.
 ***************************************************************************

	Module Name:
	omci_me_alcatel_func.c

	Abstract:

	Revision History:
	Who			When			What
	--------	----------		----------------------------------------------
	Name		Date			Modification logs
	mingang.tan	2018/8/16	Create
*/

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "errno.h"
#include "omci_adpt_common.h"
#include "omci_adpt_general.h"
#include "omci_me_alcatel.h"


int getCallHistoryTable(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setDownStreamTagHandlingModeValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setVlanTxDefaultTagValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setVlanTxBehaviorTableValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setVlanRxPolicerTableValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getEthernetPortToPortTrafficEnableIndicatorValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setEthernetPortToPortTrafficEnableIndicatorValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);

extern mb_uni_ani_port_t ani_uni_port[MAX_GEM_PORT_NUM];
extern mb_all_gemport_t ani_gemport[MAX_GEM_PORT_NUM];

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   VoIP Call statistics
********************************************************************************************************************************/


static attribute_func_t voipCallHistoryTableGetFunc = {
	getCallHistoryTable,
	NULL,
};


omci_attr_dscp_t omci_attr_alcatel_voip_call_statistics_op[]={
{0, "meId",                 2,  ATTR_ACCESS_R,  ATTR_FORMAT_UNSIGNED_INT,   ATTR_FULLY_SUPPORT,&generalAttrFunc},
{1, "Call History Table",   120,ATTR_ACCESS_R,  ATTR_FORMAT_TABLE,          ATTR_FULLY_SUPPORT,  &voipCallHistoryTableGetFunc},
{255, "", 0, 0, 0, 0, NULL} 
};

omci_me_func_t omci_me_alcatel_voip_call_statistics_op ={
	omci_me_general_create_op,
	omci_me_general_delete_op,
	omci_me_general_set_op,
	omci_me_general_get_op,
};

omci_alcatel_voip_call_statistics_t omci_alcatel_voip_call_statistics_attr_data = {0};

omci_attr_t omci_alcatel_voip_call_statistics_attr={
	(uint8_t *)&omci_alcatel_voip_call_statistics_attr_data,
	sizeof(omci_alcatel_voip_call_statistics_attr_data),
};

/****************************************************************************************************************************
ALCATEL Vendor Specific ME:   Clock Data Set
******************************************************************************************************************************/
omci_attr_dscp_t omci_attr_alcatel_clock_data_set_op[]={
{0, "meId",             2, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&generalAttrFunc},   
{1, "Domain",           1, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT,&generalAttrFunc},
{2, "Clock class",      1, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&generalAttrFunc},
{3, "Clock accuracy",   1, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_ENUM,            ATTR_FULLY_SUPPORT,&generalAttrFunc},
{4, "Clock priority1",  1, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&generalAttrFunc},
{5, "Clock priority2",  1, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,&generalAttrFunc},
{255, "", 0, 0, 0, 0, NULL} 
};

omci_me_func_t omci_me_alcatel_clock_data_set_op ={
	omci_me_general_create_op,
	omci_me_general_delete_op,
	omci_me_general_set_op,
	omci_me_general_get_op,
};

omci_alcatel_clock_data_set_t omci_alcatel_clock_data_set_attr_data = {0};

omci_attr_t omci_alcatel_clock_data_set_attr={
	(uint8_t *)&omci_alcatel_clock_data_set_attr_data,
	sizeof(omci_alcatel_clock_data_set_attr_data),
};


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   PTP Master Configure Data Profile
********************************************************************************************************************************/

omci_attr_dscp_t omci_attr_alcatel_ptp_mst_cfg_op[]={
{0, "meId",                        2,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_UNSIGNED_INT,   ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{1, "Clock Data Set Pointer",      2,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_POINTER,        ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{2, "Step mode",                   1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_UNSIGNED_INT,   ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{3, "Delay mechanism",             1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_UNSIGNED_INT,   ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{4, "Interval of sync message",    1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_SIGNED_INT,     ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{5, "Interval of delay message",   1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_SIGNED_INT,     ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{6, "Interval of pdelay message",  1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_SIGNED_INT,   	ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{7, "Interval of announce message",1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_SIGNED_INT, 	ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{255, "", 0, 0, 0, 0, NULL} 
};

omci_me_func_t omci_me_alcatel_ptp_mst_cfg_op ={
	omci_me_general_create_op,
	omci_me_general_delete_op,
	omci_me_general_set_op,
	omci_me_general_get_op,
};

omci_alcatel_ptp_master_cfg_data_ptr omci_alcatel_ptp_mst_cfg_attr_data = {0};

omci_attr_t omci_alcatel_ptp_mst_cfg_attr={
	(uint8_t *)&omci_alcatel_ptp_mst_cfg_attr_data,
	sizeof(omci_alcatel_ptp_mst_cfg_attr_data),
};

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   PTP Port
********************************************************************************************************************************/

omci_attr_dscp_t omci_attr_alcatel_ptp_port_op[]={
 {0, "meId",                               2, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,  ATTR_FULLY_SUPPORT,   &generalAttrFunc},
 {1, "PTP Master Configure Data pointer",  2, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_POINTER,       ATTR_FULLY_SUPPORT,   &generalAttrFunc},
 {2, "PPTP UNI pointer",                   2, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_POINTER,       ATTR_FULLY_SUPPORT,   &generalAttrFunc},
 {3, "Admin state",                        1, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_ENUM,          ATTR_FULLY_SUPPORT,   &generalAttrFunc},
 {4, "TCI",                                2, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,  ATTR_FULLY_SUPPORT,   &generalAttrFunc},
 {255, "", 0, 0, 0, 0, NULL} 
};

omci_me_func_t omci_me_alcatel_ptp_port_op ={
	omci_me_general_create_op,
	omci_me_general_delete_op,
	omci_me_general_set_op,
	omci_me_general_get_op,
};

omci_alcatel_ptp_port_t omci_alcatel_ptp_port_attr_data = {0};

omci_attr_t omci_alcatel_ptp_port_attr={
	(uint8_t *)&omci_alcatel_ptp_port_attr_data,
	sizeof(omci_alcatel_ptp_port_attr_data),
};

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   UNI Supplemental 1 V2
********************************************************************************************************************************/
static attribute_func_t downStreamTagHandlingModeFunc = {
    NULL,
    setDownStreamTagHandlingModeValue,
};

omci_attr_dscp_t omci_attr_alcatel_uni_supply_1v2_op[]={
{0, "meId",                             2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{1, "Downstream Tag Handling Mode",     1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,  &downStreamTagHandlingModeFunc},
{2, "IGMP Access Control Method",       1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{3, "Multicast VID Value",              2,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{4, "Multicast P-Bit Value",            1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{5, "IGMPChannelBridgePortNumber",      1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{6, "Upstream Default Priority",        1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{7, "Maximum Number of Hosts per UNI",  1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{255, "", 0, 0, 0, 0, NULL} 
};

omci_me_func_t omci_me_alcatel_uni_supply_1v2_op ={
	omci_me_general_create_op,
	omci_me_general_delete_op,
	omci_me_general_set_op,
	omci_me_general_get_op,
};

omci_alcatel_uni_supply_1v2_t omci_alcatel_uni_supply_1v2_attr_data = {0};

omci_attr_t omci_alcatel_uni_supply_1v2_attr={
	(uint8_t *)&omci_alcatel_uni_supply_1v2_attr_data,
	sizeof(omci_alcatel_uni_supply_1v2_attr_data),
};

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Total GEM Port PM

********************************************************************************************************************************/

omci_attr_dscp_t omci_attr_alcatel_total_gemport_pm_op[]={
{0, "meId" ,                                2 , ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{1, "Interval end time" ,                   1 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{2, "Threshold data 1/2 id",                2 , ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{3, "Lost GEM Fragment Counter Downstream", 4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{4, "Lost GEM Fragment Counter Upstream",   4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{5, "Received GEM Fragment Counter",        5 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{6, "Received GEM Blocks",                  5 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{7, "Transmitted GEM Blocks" ,              5 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{8, "Impaired blocks" ,                     4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{9, "Transmitted GEM Fragment Counter" ,    5 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{10, "Bad GEM Headers Received Counter" ,   4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{11, "Received GEM Blocks 64Bit" ,          8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{12, "Transmitted GEM Blocks 64Bit" ,       8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{255, "", 0, 0, 0, 0, NULL} 
};

int get_all_gemport_data(TotalGemPortPmcounters_t *data, uint16_t portId)
{
    int portID = 0;
    GEM_STATISTIC_t gponGemCounter ={0};
	int i = 0;

    if(data == NULL){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] ->NULL pointer\n", __FUNCTION__,__LINE__);
		return -1;
	}

	for(i = 0; i < MAX_GEM_PORT_NUM; i++){
		if(ani_gemport[i].valid){
			portID = ani_gemport[i].gemportId;
			if(0 != gponmgr_lib_get_gemcounter(portId, &gponGemCounter)) {
				omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d] :  gponmgr_lib_get_gemcounter fail\n",__FUNCTION__, __LINE__);
				return -1;
			}
			data->receivedBlocks += (gponGemCounter.rxGemPayload / 48);
			data->transmittedBlocks += (gponGemCounter.txGemPayload / 48);
			data->receivedBlocks64 += (gponGemCounter.rxGemPayload / 48);
			data->transmittedBlocks64 += (gponGemCounter.rxGemPayload / 48);
		}
	}
    return 0;
}

int get_alcatel_total_gemport_pm_history_data(pm_history_data_list_ptr pm_list, uint8_t syncFlag)
{  
    uint64_t longVal = 0;
    TotalGemPortPmcounters_t totalGem = {0};

    if(pm_list == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  pm list is NULL\n",__FUNCTION__,__LINE__);
        return -1;
    }

	if(0 != get_all_gemport_data(&totalGem, pm_list->instId)) {
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d] :  get_all_gemport_statistics fail\n",__FUNCTION__, __LINE__);
		return -1;
	}

    if(syncFlag)
    {
        pm_list->pm_data.alcatel_total_gem_pm.interEndTime = pmIntervalTimes;
        pm_list->pm_data.alcatel_total_gem_pm.lostGemFrameCntDown = 0;
        pm_list->pm_data.alcatel_total_gem_pm.lostGemFrameCnUp = 0;
        //pm_list->pm_data.alcatel_total_gem_pm.rcvGemFrameCnt = 0;
    	//pm_list->pm_data.alcatel_total_gem_pm.transGemFrameCnt = 0;
    	pm_list->pm_data.alcatel_total_gem_pm.badGemHeaderRcsCnt = 0;
    	pm_list->pm_data.alcatel_total_gem_pm.impairedBlock = 0;

    	
    	
    	longVal = pm_list->pm_prev_data.alcatelTotalGem.receivedBlocks - totalGem.receivedBlocks;    	
    	pm_list->pm_data.alcatel_total_gem_pm.rcvGemBlock[0] = (longVal >> 32) &0xFF;
    	put32(&pm_list->pm_data.alcatel_total_gem_pm.rcvGemBlock[1], (uint32_t)(longVal & 0xFFFF));

    	longVal = pm_list->pm_prev_data.alcatelTotalGem.receivedBlocks64- totalGem.receivedBlocks64;
        pm_list->pm_data.alcatel_total_gem_pm.rcvGemBlock64bit = longVal;
    	

    	longVal = pm_list->pm_prev_data.alcatelTotalGem.transmittedBlocks- totalGem.transmittedBlocks;    	
    	pm_list->pm_data.alcatel_total_gem_pm.TransGemBlock[0] = (longVal >> 32) &0xFF;
    	put32(&pm_list->pm_data.alcatel_total_gem_pm.TransGemBlock[1], (uint32_t)(longVal & 0xFFFF));

    	longVal = pm_list->pm_prev_data.alcatelTotalGem.transmittedBlocks64- totalGem.transmittedBlocks64;
        pm_list->pm_data.alcatel_total_gem_pm.transGemBlock64bit= longVal;

    }

	memcpy(&pm_list->pm_prev_data.alcatelTotalGem, &totalGem, sizeof(TotalGemPortPmcounters_t));
    return 0;
}

int omci_me_alcatel_total_gemport_pm_history_get_curr_op(management_entry_ptr me_entry, omci_me_info_ptr me_info)
{
    omci_alcatel_total_gemport_pm_ptr total_gem_pm = NULL;
    TotalGemPortPmcounters_t totalGem = {0};
    uint64_t longVal = 0;

    if(me_entry == NULL || me_info == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]pointer is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }
    total_gem_pm = (omci_alcatel_total_gemport_pm_ptr)me_info->attributes;

    if(total_gem_pm == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]me info attribute is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }
    
	if(0 != get_all_gemport_data(&totalGem, me_info->inst_id)) {
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d] :  get_all_gemport_statistics fail\n",__FUNCTION__, __LINE__);
		return -1;
	}

	total_gem_pm->interEndTime = pmIntervalTimes;
	total_gem_pm->lostGemFrameCntDown = 0;
	total_gem_pm->lostGemFrameCnUp = 0;
	total_gem_pm->impairedBlock = 0;
	total_gem_pm->badGemHeaderRcsCnt = 0;
	total_gem_pm->rcvGemBlock64bit = totalGem.receivedBlocks64;
	total_gem_pm->transGemBlock64bit = totalGem.transmittedBlocks64;

	longVal = totalGem.receivedBlocks;    
    total_gem_pm->rcvGemBlock[0] = (longVal >> 32) &0xFF;
    put32(&total_gem_pm->rcvGemBlock[1], (uint32_t)(longVal & 0xFFFF));

	longVal = totalGem.transmittedBlocks;	
    total_gem_pm->TransGemBlock[0] = (longVal >> 32) &0xFF;
    put32(&total_gem_pm->TransGemBlock[1], (uint32_t)(longVal & 0xFFFF));

    return 0;
}

int omci_me_alcatel_total_gemport_pm_history_notify(pm_history_data_list_ptr pm_list, omci_me_info_t threshold_info)
{
    enum{ ALCATEL_TOTAL_GEM_PORT_PM_HISTORY_DATA_TCA_NUM = 4};
    omci_threshold_data_1_ptr threshold_data1 = NULL;
    int i = 1;
    uint32_t currentData[ALCATEL_TOTAL_GEM_PORT_PM_HISTORY_DATA_TCA_NUM] = {0};
    static uint8_t reportFlag[ALCATEL_TOTAL_GEM_PORT_PM_HISTORY_DATA_TCA_NUM] = {0};
    uint8_t alarm_num[ALCATEL_TOTAL_GEM_PORT_PM_HISTORY_DATA_TCA_NUM] = {0, 1, 2, 3};
    tca_notify_info_t tca_info = {0};

    if(pm_list == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  pm_list is NULL fail\n",__FUNCTION__,__LINE__);
        return -1;
    }
    if(omci_pm_is_end_of_interval_time())
    {
        memset(reportFlag, 0, sizeof(reportFlag));
        return 0;
    }
    if(threshold_info.class_id != OMCI_CLASS_ID_THRESHOLD_DATA1){
        return 0;
    }

	threshold_data1 =  (omci_threshold_data_1_ptr)threshold_info.attributes;
	if(threshold_data1 == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  threshold value is NULL \n",__FUNCTION__,__LINE__);
        return -1;
    }
    
    //because of driver does not implement, the four attribute is 0.    

    for(i = 0; i < ALCATEL_TOTAL_GEM_PORT_PM_HISTORY_DATA_TCA_NUM; i++)
    {
        tca_info.classId = pm_list->classId;
        tca_info.instId = pm_list->instId;
        tca_info.currentData = currentData[i];
        tca_info.threshold = threshold_data1->thresholdValue[i];
        tca_info.alarm_num = alarm_num[i];
        tca_info.reportFlag = reportFlag[i];

        reportFlag[i] = omci_pm_report_alarm_by_tca_info(tca_info, 0);
	}

	return 0;
    
}


omci_me_func_t omci_me_alcatel_total_gemport_pm_op ={
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_set_op,
	omci_me_general_pm_history_get_op,
	omci_me_alcatel_total_gemport_pm_history_get_curr_op
};

omci_alcatel_total_gemport_pm_t omci_alcatel_total_gemport_pm_attr_data = {0};

omci_attr_t omci_alcatel_total_gemport_pm_attr={
	(uint8_t *)&omci_alcatel_total_gemport_pm_attr_data,
	sizeof(omci_alcatel_total_gemport_pm_attr_data),
};


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Ethernet Traffic PM

********************************************************************************************************************************/

omci_attr_dscp_t omci_attr_alcatel_eth_traffic_pm_op[]={
{0, "meId" , 									2 , ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{1, "Interval end time" , 						1 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{2, "Threshold data 1/2 id", 					2 , ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{3, "Upstream Frames Counter",					4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{4, "Downstream Frames Counter", 				4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{5, "Upstream Bytes Counter",					4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{6, "Downstream Bytes Counter",					4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{7, "Dropped Upstream Frames Counter" ,			4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{8, "Dropped Upstream Bytes Counter" ,			4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{9, "Dropped Downstream Frames Counter" , 		4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{10, "Multicast Upstream Frames Counter" , 		4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{11, "Multicast Downstream Frames Counter" ,	4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{12, "Upstream Bytes Counter 64Bit" , 			8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{13, "Downstream Bytes Counter 64Bit" , 		8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{14, "Upstream Frames Counter 64Bit" , 			8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{15, "Downstream Frames Counter 64Bit" , 		8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{255, "" , 0 ,0 ,0 , 0 ,NULL}
};


int get_eth_traffic_data(EthernetTrafficPmcounters_t *data, uint16_t portId)
{
	uint32_t tempPortId = 0;
	uint32_t cnt = 0;

	if(data == NULL){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] ->NULL pointer\n", __FUNCTION__,__LINE__);
		return -1;
	}
	
	memset(data, 0, sizeof(EthernetTrafficPmcounters_t));
	tempPortId = (portId & 0xFF)-1;		
	
	if(macMT7530GetPortRxOctetsCnt(tempPortId, &cnt) == 0){
		data->UpstreamBytes = cnt;
	}	
	if(macMT7530GetPortTxOctetsCnt(tempPortId, &cnt) == 0){
		data->DownstreamBytes = cnt;
	}
	
	if(macMT7530GetPortRxPktsCnt(tempPortId, &cnt) == 0){
		data->UpstreamFrames = cnt;
	}
	if(macMT7530GetPortTxPktsCnt(tempPortId, &cnt) == 0){
		data->DownstreamFrames = cnt;
	}
	
	if(macMT7530GetPortRxMultiPktsCnt(tempPortId, &cnt) == 0){
		data->MulticastUpstreamFrames = cnt;
	}
	if(macMT7530GetPortTxMultiPktsCnt(tempPortId, &cnt) == 0){
		data->MulticastDownstreamFrames = cnt;
	}

	if(macMT7530GetPortRxDropFramesCnt(tempPortId, &cnt) == 0){
		data->DropUpstreamFrames = cnt;
	}
	if(macMT7530GetPortTxDropFramesCnt(tempPortId, &cnt) == 0){
		data->DropDownstreamFrames = cnt;
	}
	
	data->UpstreamBytes64 = data->UpstreamBytes;
	data->DownstreamBytes64 = data->DownstreamBytes;
	data->UpstreamFrames64 = data->UpstreamFrames;
	data->DownstreamFrames64 = data->DownstreamFrames;

	return 0;
}


int get_alcatel_eth_traffic_pm_history_data(pm_history_data_list_ptr pm_list, uint8_t syncFlag)
{
    EthernetTrafficPmcounters_t ethTraffic = {0};

    if(pm_list == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  pm list is NULL\n",__FUNCTION__,__LINE__);
        return -1;
    }

	if(0 != get_eth_traffic_data(&ethTraffic, pm_list->instId)) {
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d] :  get_all_gemport_statistics fail\n",__FUNCTION__, __LINE__);
		return -1;
	}

    if(syncFlag)
    {
        pm_list->pm_data.alcatel_eth_pm.interEndTime = pmIntervalTimes;
        pm_list->pm_data.alcatel_eth_pm.upFrameCnt = pm_list->pm_prev_data.alcatelEthTraffic.UpstreamFrames - ethTraffic.UpstreamFrames;
        pm_list->pm_data.alcatel_eth_pm.downFrameCnt= pm_list->pm_prev_data.alcatelEthTraffic.DownstreamFrames- ethTraffic.DownstreamFrames;
        pm_list->pm_data.alcatel_eth_pm.upBytesCnt= pm_list->pm_prev_data.alcatelEthTraffic.UpstreamBytes- ethTraffic.UpstreamBytes;
        pm_list->pm_data.alcatel_eth_pm.downBytesCnt= pm_list->pm_prev_data.alcatelEthTraffic.DownstreamBytes- ethTraffic.DownstreamBytes;
        pm_list->pm_data.alcatel_eth_pm.dropUpFrameCnt= pm_list->pm_prev_data.alcatelEthTraffic.DropUpstreamFrames- ethTraffic.DropUpstreamFrames;
        pm_list->pm_data.alcatel_eth_pm.dropUpBytesCnt= pm_list->pm_prev_data.alcatelEthTraffic.DropUpstreamBytes- ethTraffic.DropUpstreamBytes;
        pm_list->pm_data.alcatel_eth_pm.dropDownFrameCnt= pm_list->pm_prev_data.alcatelEthTraffic.DropDownstreamFrames- ethTraffic.DropDownstreamFrames;
        pm_list->pm_data.alcatel_eth_pm.multicastUpFrameCnt= pm_list->pm_prev_data.alcatelEthTraffic.MulticastUpstreamFrames- ethTraffic.MulticastUpstreamFrames;
        pm_list->pm_data.alcatel_eth_pm.multicastDownFrameCnt= pm_list->pm_prev_data.alcatelEthTraffic.MulticastDownstreamFrames- ethTraffic.MulticastDownstreamFrames;
        pm_list->pm_data.alcatel_eth_pm.upBytesCnt64bit= pm_list->pm_prev_data.alcatelEthTraffic.UpstreamBytes64- ethTraffic.UpstreamBytes64;
        pm_list->pm_data.alcatel_eth_pm.downBytesCnt64bit= pm_list->pm_prev_data.alcatelEthTraffic.DownstreamBytes64- ethTraffic.DownstreamBytes64;
        pm_list->pm_data.alcatel_eth_pm.upFrameCnt64bit= pm_list->pm_prev_data.alcatelEthTraffic.UpstreamFrames64- ethTraffic.UpstreamFrames64;
        pm_list->pm_data.alcatel_eth_pm.downFrameCnt64bit= pm_list->pm_prev_data.alcatelEthTraffic.DownstreamFrames64- ethTraffic.DownstreamFrames64;
    }

	memcpy(&pm_list->pm_prev_data.alcatelEthTraffic, &ethTraffic, sizeof(EthernetTrafficPmcounters_t));
    return 0;
}

int omci_me_alcatel_eth_traffic_pm_history_get_curr_op(management_entry_ptr me_entry, omci_me_info_ptr me_info)
{
    omci_alcatel_eth_traffic_pm_ptr eth_traffic_pm = NULL;
    EthernetTrafficPmcounters_t ethTraffic = {0};

    if(me_entry == NULL || me_info == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]pointer is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }
    eth_traffic_pm = (omci_alcatel_eth_traffic_pm_ptr)me_info->attributes;

    if(eth_traffic_pm == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]me info attribute is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }
    
	if(0 != get_eth_traffic_data(&ethTraffic, me_info->inst_id)) {
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d] :  get_all_gemport_statistics fail\n",__FUNCTION__, __LINE__);
		return -1;
	}

	eth_traffic_pm->interEndTime = pmIntervalTimes;	
	eth_traffic_pm->upFrameCnt = ethTraffic.UpstreamFrames;
	eth_traffic_pm->downFrameCnt= ethTraffic.DownstreamFrames;
	eth_traffic_pm->upBytesCnt= ethTraffic.UpstreamBytes;
	eth_traffic_pm->downBytesCnt= ethTraffic.DownstreamBytes;
	eth_traffic_pm->dropUpFrameCnt= ethTraffic.DropUpstreamFrames;
	eth_traffic_pm->dropUpBytesCnt= ethTraffic.DropUpstreamBytes;
	eth_traffic_pm->dropDownFrameCnt= ethTraffic.DropDownstreamFrames;  
    eth_traffic_pm->multicastUpFrameCnt= ethTraffic.MulticastUpstreamFrames;
    eth_traffic_pm->multicastDownFrameCnt= ethTraffic.MulticastDownstreamFrames;
	eth_traffic_pm->upBytesCnt64bit= ethTraffic.UpstreamBytes64;
    eth_traffic_pm->downBytesCnt64bit= ethTraffic.DownstreamBytes64;
    eth_traffic_pm->upFrameCnt64bit= ethTraffic.UpstreamFrames64;
    eth_traffic_pm->downFrameCnt64bit= ethTraffic.DownstreamFrames64;
    
    return 0;
}

int omci_me_alcatel_eth_traffic_pm_history_notify(pm_history_data_list_ptr pm_list, omci_me_info_t threshold_info)
{
    enum{ ALCATEL_ETH_TRAFFIC_PM_HISTORY_DATA_TCA_NUM = 3};
    omci_threshold_data_1_ptr threshold_data1 = NULL;
    int i = 1;
    uint32_t currentData[ALCATEL_ETH_TRAFFIC_PM_HISTORY_DATA_TCA_NUM] = {0};
    static uint8_t reportFlag[ALCATEL_ETH_TRAFFIC_PM_HISTORY_DATA_TCA_NUM] = {0};
    uint8_t alarm_num[ALCATEL_ETH_TRAFFIC_PM_HISTORY_DATA_TCA_NUM] = {0, 1, 2};
    tca_notify_info_t tca_info = {0};
    EthernetTrafficPmcounters_t ethTraffic = {0};

    if(pm_list == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  pm_list is NULL fail\n",__FUNCTION__,__LINE__);
        return -1;
    }
    if(omci_pm_is_end_of_interval_time())
    {
        memset(reportFlag, 0, sizeof(reportFlag));
        return 0;
    }
    if(threshold_info.class_id != OMCI_CLASS_ID_THRESHOLD_DATA1){
        return 0;
    }

	threshold_data1 =  (omci_threshold_data_1_ptr)threshold_info.attributes;
	if(threshold_data1 == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  threshold value is NULL \n",__FUNCTION__,__LINE__);
        return -1;
    }

    if(0 != get_eth_traffic_data(&ethTraffic, pm_list->instId)) {
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s][%d] :  get_all_gemport_statistics fail\n",__FUNCTION__, __LINE__);
		return -1;
	}

	
    currentData[0] = ethTraffic.DropUpstreamFrames - pm_list->pm_prev_data.alcatelEthTraffic.DropUpstreamFrames;
    currentData[1] = ethTraffic.DropUpstreamBytes - pm_list->pm_prev_data.alcatelEthTraffic.DropUpstreamBytes;
    currentData[2] = ethTraffic.DropDownstreamFrames - pm_list->pm_prev_data.alcatelEthTraffic.DropDownstreamFrames;

    for(i = 0; i < ALCATEL_ETH_TRAFFIC_PM_HISTORY_DATA_TCA_NUM; i++)
    {
        tca_info.classId = pm_list->classId;
        tca_info.instId = pm_list->instId;
        tca_info.currentData = currentData[i];
        tca_info.threshold = threshold_data1->thresholdValue[i];
        tca_info.alarm_num = alarm_num[i];
        tca_info.reportFlag = reportFlag[i];

        reportFlag[i] = omci_pm_report_alarm_by_tca_info(tca_info, 0);
	}

	return 0;
    
}

omci_me_func_t omci_me_alcatel_eth_traffic_pm_op ={
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_set_op,
	omci_me_general_pm_history_get_op,
	omci_me_alcatel_eth_traffic_pm_history_get_curr_op
};

omci_alcatel_eth_traffic_pm_t omci_alcatel_eth_traffic_pm_attr_data = {0};

omci_attr_t omci_alcatel_eth_traffic_pm_attr={
	(uint8_t *)&omci_alcatel_eth_traffic_pm_attr_data,
	sizeof(omci_alcatel_eth_traffic_pm_attr_data),
};

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Vlan Tag Downstream Egress Behavior Supplemental 1

********************************************************************************************************************************/

static attribute_func_t VlanTxDefaultTagFunc = {
    NULL,
    setVlanTxDefaultTagValue,
};

static attribute_func_t VlanTxBehaviorTableFunc = {
    NULL,
    setVlanTxBehaviorTableValue,
};


omci_attr_dscp_t omci_attr_alcatel_vlan_tag_down_supply_1_op[]={
{0, "meId" , 					2 , ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{1, "Vlan Tx Default Tag" ,		1 , ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &VlanTxDefaultTagFunc},
{2, "Vlan Tx Behavior Table" ,	6 , ATTR_ACCESS_R_W,    ATTR_FORMAT_TABLE,           ATTR_FULLY_SUPPORT, &VlanTxBehaviorTableFunc},
{255, "" , 0 ,0 ,0 , 0 ,NULL}
};

omci_me_func_t omci_me_alcatel_vlan_tag_down_supply_1_op ={
	omci_me_general_create_op,
	omci_me_general_delete_op,
	omci_me_general_set_op,
	omci_me_general_get_op,
};

omci_alcatel_vlan_tag_down_supply1_t omci_alcatel_vlan_tag_down_supply_1_attr_data = {0};

omci_attr_t omci_alcatel_vlan_tag_down_supply_1_attr={
	(uint8_t *)&omci_alcatel_vlan_tag_down_supply_1_attr_data,
	sizeof(omci_alcatel_vlan_tag_down_supply_1_attr_data),
};

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Vlan Tag Upstream Policer

********************************************************************************************************************************/

static attribute_func_t VlanRxPolicerTableFunc = {
    NULL,
#if defined (TCSUPPORT_UPSTREAM_VLAN_POLICER)
    setVlanRxPolicerTableValue,
#else
	NULL
#endif
};


omci_attr_dscp_t omci_attr_alcatel_vlan_tag_up_policy_op[]={
{0, "meId" ,                    2 , ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   ATTR_FULLY_SUPPORT,  &generalAttrFunc},
{1, "Vlan Rx Policer Table" ,   19, ATTR_ACCESS_W,      ATTR_FORMAT_TABLE,          ATTR_FULLY_SUPPORT,  &VlanRxPolicerTableFunc},
{255, "" ,0 ,0 ,0 , 0 ,NULL}
};

omci_me_func_t omci_me_alcatel_vlan_tag_up_policy_op ={
	omci_me_general_create_op,
	omci_me_general_delete_op,
	omci_me_general_set_op,
	omci_me_general_get_op,
};

omci_alcatel_vlan_tag_up_policy_t omci_alcatel_vlan_tag_up_policy_attr_data = {0};

omci_attr_t omci_alcatel_vlan_tag_up_policy_attr={
	(uint8_t *)&omci_alcatel_vlan_tag_up_policy_attr_data,
	sizeof(omci_alcatel_vlan_tag_up_policy_attr_data),
};

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   GEMPort Protocol Monitoring History Data - Part 2

********************************************************************************************************************************/

omci_attr_dscp_t omci_attr_alcatel_gemport_protocol_pm_op[]={
{0, "meId",                                     2,  ATTR_ACCESS_R_SET_CREATE,       ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},                               
{1, "interval end time",                        1,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{2, "threshold data 1/2 id",                    2,  ATTR_ACCESS_R_W_SET_CREATE,     ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{3, "Lost GEM Fragment Counter(Upstream)",      4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{4, "Transmitted GEM Fragment Counter",         5,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{255, "" ,0 ,0 ,0 , 0 ,NULL}
};

int get_alcatel_gemport_2_pm_history_data(pm_history_data_list_ptr pm_list, uint8_t syncFlag)
{  
    if(pm_list == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]  pm list is NULL\n",__FUNCTION__,__LINE__);
        return -1;
    }

    if(syncFlag)
    {
        pm_list->pm_data.alcatel_gem2_pm.interEndTime= pmIntervalTimes;
    }

	//memcpy(&pm_list->pm_prev_data.alcatelGem2, &totalGem, sizeof(GEMPortProtocolPmcounters_t));
    return 0;
}

int omci_me_alcatel_gemport_2_pm_history_get_curr_op(management_entry_ptr me_entry, omci_me_info_ptr me_info)
{
    omci_alcatel_gemport_protocol_pm_ptr gem = NULL;


    if(me_entry == NULL || me_info == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]pointer is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }
    gem = (omci_alcatel_gemport_protocol_pm_ptr)me_info->attributes;

    if(gem == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]me info attribute is NULL.\n",__FUNCTION__,__LINE__);
        return -1;
    }
    
	gem->interEndTime = pmIntervalTimes;

    return 0;
}

omci_me_func_t omci_me_alcatel_gemport_protocol_pm_op ={
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_create_del_op,
	omci_me_general_pm_history_set_op,
	omci_me_general_pm_history_get_op,
	omci_me_alcatel_gemport_2_pm_history_get_curr_op
};

omci_alcatel_gemport_protocol_pm_t omci_alcatel_gemport_protocol_pm_attr_data = {0};

omci_attr_t omci_alcatel_gemport_protocol_pm_attr={
	(uint8_t *)&omci_alcatel_gemport_protocol_pm_attr_data,
	sizeof(omci_alcatel_gemport_protocol_pm_attr_data),
};

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   ONT Optical Supervision Status

********************************************************************************************************************************/

omci_attr_dscp_t omci_attr_alcatel_ont_optical_Status_op[]={
{0, "meId",                                         2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{1, "Power feed voltage measurement indicator",     1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{2, "Power Feed Voltage",                           2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{3, "Receive optical power measurement indicator",  1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{4, "Receive Optical Power",                        2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{5, "Transmit optical power measurement indicator", 1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{6, "Transmit Optical Power",                       2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{7, "Laser Bias Current measurement indicator",     1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{8, "Laser Bias Current",                           2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{9, "Temperature measurement indicator",            1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{10, "Temperature",                                 2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{255, "" , 0 ,0 ,0 , 0 ,NULL}
};

int omci_me_alcatel_ont_optical_get_op(management_entry_ptr me_entry, omci_me_info_ptr me_info)
{
    PHY_PARAMS_t pPhyTransParams;
    omci_alcatel_ont_optical_status_ptr ontOptical = NULL;

    if(me_info==NULL || me_info->attributes == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] input paramter pointer is NULL\n",__FUNCTION__,__LINE__);
        return -1;
    }
	memset(&pPhyTransParams,0,sizeof(PHY_PARAMS_t));
	gponmgr_lib_get_phy_trans_params(&pPhyTransParams);

	ontOptical = (omci_alcatel_ont_optical_status_ptr)me_info->attributes;

	ontOptical->powerFeedVol = pPhyTransParams.voltage/10000;
	ontOptical->rcvOpticalPower = pPhyTransParams.rxPower/10000;
	ontOptical->transOpticalPower= pPhyTransParams.txPower/10000;
	ontOptical->laserBiasCurrent= pPhyTransParams.txCurrent * 2/(1000 * 1000);
	ontOptical->temperature= pPhyTransParams.temperature/256;
    return 0;
}

omci_me_func_t omci_me_alcatel_ont_optical_Status_op ={
	omci_me_general_create_op,
	omci_me_general_delete_op,
	omci_me_general_set_op,
	omci_me_alcatel_ont_optical_get_op,
};

omci_alcatel_ont_optical_status_t omci_alcatel_ont_optical_Status_attr_data = {0};

omci_attr_t omci_alcatel_ont_optical_Status_attr={
	(uint8_t *)&omci_alcatel_ont_optical_Status_attr_data,
	sizeof(omci_alcatel_ont_optical_Status_attr_data),
};

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   ONT Generic V2

********************************************************************************************************************************/

static attribute_func_t ethernetPortToPortTrafficEnableIndicatorFunc = {
    getEthernetPortToPortTrafficEnableIndicatorValue,
    setEthernetPortToPortTrafficEnableIndicatorValue,
};

omci_attr_dscp_t omci_attr_alcatel_ont_generic_v2_op[]={
{0, "meId",                                     2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{1, "IGMPSnoopEnable",                          1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{2, "ForceDataStorageCommand",                  1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{3, "TimeOfLastDataStorageOperation",           4,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{4, "CraftEnableDisableIndicator",              1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{5, "EthernetPortToPortTrafficEnableIndicator", 1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &ethernetPortToPortTrafficEnableIndicatorFunc},
{6, "StaticMulticastVLANTranslationIndicator",  1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{7, "ALUProprietaryMECapabilitiesBitmap",       4,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{8, "FlexiblePQAssignmentCapability",           1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{9, "SLIDCapability",                           1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{10, "YPSerialNumber",                          12, ATTR_ACCESS_R,      ATTR_FORMAT_STRING,          ATTR_FULLY_SUPPORT, &generalAttrFunc},
{11, "ALUSpecialBehaviorsField",                4,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{12, "ALUProprietaryMECapabilitiesBitmapPart2", 25, ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,    ATTR_FULLY_SUPPORT, &generalAttrFunc},
{255, "" , 0 ,0 ,0 , 0 ,NULL}
};

omci_me_func_t omci_me_alcatel_ont_generic_v2_op ={
	omci_me_general_create_op,
	omci_me_general_delete_op,
	omci_me_general_set_op,
	omci_me_general_get_op,
};

omci_alcatel_ont_optical_status_t omci_alcatel_ont_generic_v2_attr_data = {0};

omci_attr_t omci_alcatel_ont_generic_v2_attr={
	(uint8_t *)&omci_alcatel_ont_generic_v2_attr_data,
	sizeof(omci_alcatel_ont_generic_v2_attr_data),
};



/*****************************************FUNCTION***********************************************/
/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   VoIP Call statistics
********************************************************************************************************************************/

int getCallHistoryTable(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
    omci_alcatel_voip_call_statistics_ptr voipCallS = NULL;
    callHistory_ptr callHistory_p = NULL;
    int len = 0;
    int i = 0;
    if(me_info==NULL || me_info->attributes == NULL)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] input paramter pointer is NULL\n",__FUNCTION__,__LINE__);
		return -1;
	}

	voipCallS = (omci_alcatel_voip_call_statistics_ptr)me_info->attributes;

    callHistory_p = (callHistory_ptr)(voipCallS->callHistoryTbl.buf);

    len += omci_attr->attriLen;
	for(i = 0; len <= voipCallS->callHistoryTbl.len; i++)
	{
	    memset(callHistory_p[i].date,0,sizeof(callHistory_p[i].date));
        memset(callHistory_p[i].time,0,sizeof(callHistory_p[i].time));
        callHistory_p[i].callDuration=-1;
        memset(callHistory_p[i].calledNumber,0,sizeof(callHistory_p[i].calledNumber));
        memset(callHistory_p[i].callingNumber,0,sizeof(callHistory_p[i].callingNumber));
        callHistory_p[i].RTPTxPackets      =-1;
        callHistory_p[i].RTPRxPackets      =-1;
        callHistory_p[i].RTPRxPacketsLost  =-1;
        callHistory_p[i].RTPPacketsDiscards=-1;
        callHistory_p[i].RTPOverruns       =-1;
        callHistory_p[i].RTPUnderruns      =-1;
        callHistory_p[i].AverageJitter     =-1;
        callHistory_p[i].RTCPParticipation =0xFF;
        callHistory_p[i].PeakJitter        =-1;
        callHistory_p[i].AverageJitterBufferDepth =-1;
        callHistory_p[i].RTCP_XRParticipation  =0xFF;
        callHistory_p[i].AverageMOS        =-1;
        callHistory_p[i].PeakRoundTripDelay=-1;
        callHistory_p[i].AverageRoundTripDelay =-1;
	    len += omci_attr->attriLen;
	}
    return 0;
}


/****************************************************************************************************************************
ALCATEL Vendor Specific ME:   Clock Data Set
******************************************************************************************************************************/


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   PTP Master Configure Data Profile
********************************************************************************************************************************/


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   PTP Port
********************************************************************************************************************************/


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   UNI Supplemental 1 V2
********************************************************************************************************************************/

int setDownStreamTagHandlingModeValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
    omci_alcatel_uni_supply_1v2_ptr uniSupply1V2 = NULL;
    uint16_t portId = 0;
    FILE *fp = NULL;
    
    if(me_info==NULL || me_info->attributes == NULL)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] input paramter pointer is NULL\n",__FUNCTION__,__LINE__);
		return -1;
	}

	uniSupply1V2 = (omci_alcatel_uni_supply_1v2_ptr)me_info->attributes;

	portId = (me_info->inst_id & 0xFF)-1;

	fp = fopen("/proc/tc3162/eth_down_vlan", "w");
	if (!fp)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] fopen fail\n",__FUNCTION__,__LINE__);
		return -1;
	}
	else
	{
		if ((uniSupply1V2->downTagHandleMode == 1) || (uniSupply1V2->downTagHandleMode == 2)) // 1: STRIP TAG Mode; 2: TAG THRU Mode.
		{
			fprintf(fp, "set_defop %d %d\n", portId, uniSupply1V2->downTagHandleMode);
			fclose(fp);
		}
		else
		{
			fclose(fp);
			omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] input paramter pointer is NULL\n",__FUNCTION__,__LINE__);
			return -1;
		}
	}
    return 0;
}

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Total GEM Port PM

********************************************************************************************************************************/


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Ethernet Traffic PM

********************************************************************************************************************************/


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Vlan Tag Downstream Egress Behavior Supplemental 1

********************************************************************************************************************************/
int setVlanTxDefaultTagValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
    omci_alcatel_vlan_tag_down_supply1_ptr vlanTagDown = NULL;
    uint16_t portId = 0;
    FILE *fp = NULL;
    
    if(me_info==NULL || me_info->attributes == NULL)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] input paramter pointer is NULL\n",__FUNCTION__,__LINE__);
		return -1;
	}

	vlanTagDown = (omci_alcatel_vlan_tag_down_supply1_ptr)me_info->attributes;

	portId = (me_info->inst_id & 0xFF)-1;

	fp = fopen("/proc/tc3162/eth_down_vlan", "w");
	if (!fp)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] fopen fail\n",__FUNCTION__,__LINE__);
		return -1;
	}
	else
	{
		if ((vlanTagDown->vlanTxDefaultTag >= 1) && (vlanTagDown->vlanTxDefaultTag <= 3)) // 1: Remove TAG Mode; 2: TAG THRU Mode; 3: Priority TAG Mode
		{
			fprintf(fp, "set_defop %d %d\n", portId, vlanTagDown->vlanTxDefaultTag);
			fclose(fp);
		}
		else
		{
			fclose(fp);
			omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] input paramter pointer is NULL\n",__FUNCTION__,__LINE__);
			return -1;
		}
	}
    return 0;
}

int setVlanTxBehaviorTableValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
    omci_alcatel_vlan_tag_down_supply1_ptr vlanTagDown = NULL;
    uint16_t portId = 0;
    FILE *fp = NULL;
    char *tmp = NULL;
    uint8_t entryNum = 0;
    uint8_t actionType = 0;
    uint8_t tagAction = 0;
    uint16_t vlanId = 0;
    uint16_t reserved = 0;
    
    if(me_info==NULL || me_info->attributes == NULL)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] input paramter pointer is NULL\n",__FUNCTION__,__LINE__);
		return -1;
	}

	vlanTagDown = (omci_alcatel_vlan_tag_down_supply1_ptr)me_info->attributes;

	portId = (me_info->inst_id & 0xFF)-1;	

	tmp = vlanTagDown->vlanTxBehaviorTbl.buf;

	if(tmp == NULL)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] TABLE is NULL\n",__FUNCTION__,__LINE__);
		return -1;
	}
	
    fp = fopen("/proc/tc3162/eth_down_vlan", "w");
    if (!fp)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] fopen fail\n",__FUNCTION__,__LINE__);
        return -1;
    }

	entryNum = *tmp;
	actionType = (*(tmp+1) >> 7) & 0x1;
	tagAction = *(tmp+1) & 0x3;
	vlanId = get16((uint8_t *)tmp+2);
    reserved = get16((uint8_t *)tmp+4);
    
	if(actionType)
	{
	    if ((tagAction >= 1) && (tagAction <= 3)) // 1: Remove TAG Mode; 2: TAG THRU Mode; 3: Priority TAG Mode
		{
			fprintf(fp, "add_entry %d %d %d %d %d\n", portId, entryNum, tagAction, vlanId, reserved);
		}
	}
	else
	{
	    fprintf(fp, "del_entry %d %d %d %d %d\n", portId, entryNum, tagAction, vlanId, reserved);
	}
	fclose(fp);
    return 0;
}

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Vlan Tag Upstream Policer

********************************************************************************************************************************/

/*******************************************************************************************
**function name
	updateGemPortInfoToRomfile
**description:
	set ALL GEM port information to romfile()
 **retrun :
 	-1:	fail
 	0:	success
**parameter:
	NULL
********************************************************************************************/
int updateGemPortInfoToRomfile(omci_gem_interwork_tp_ptr gem_iwtp_ptr)
{
	omci_gem_port_ctp_ptr gem_ctp_ptr=NULL;
	omci_me_info_t me_info_buf={0};
	int i = 0;

	if(gem_iwtp_ptr == NULL){
		return -1;
	}
	me_info_buf.class_id = OMCI_CLASS_ID_GEM_PORT_CTP;
	me_info_buf.inst_id = gem_iwtp_ptr->gemPortNetCTPConPtr;
	if(omci_attr_get_all_data_except_table_attr(&me_info_buf) != 0){
		omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d] get attribute data fail\n",__FUNCTION__,__LINE__);
		return -1;
	}
	gem_ctp_ptr = (omci_gem_port_ctp_ptr)(me_info_buf.attributes);

	for(i = 0; i < MAX_GEM_PORT_NUM; i++){
		if(ani_gemport[i].valid == 0 && (ani_gemport[i].gemportId != gem_ctp_ptr->portId || gem_ctp_ptr->portId == 0)){
			ani_gemport[i].gemportId= gem_ctp_ptr->portId;
			ani_gemport[i].valid = 1;
			break;
		}
	}
	return 0;
}

#if defined (TCSUPPORT_UPSTREAM_VLAN_POLICER)
void InitUpStrmPolicerTrtcm(void)
{
        memset(trtcmChannel + TRTCM_CHAN_NUM_FOR_GEMPORT, 0xff, \
               sizeof(trtcmChannel[0]) * TRTCM_CHAN_NUM_FOR_UP_STRM_POLICER);   
}

static uint8_t getTrtcmChan4UpStrmPolicer(uint16_t PolicerID)
{
        uint8_t channelId = TRTCM_CHAN_NUM_FOR_GEMPORT;

        /* search the id using channel id */
        for (; channelId < CONST_SHAPING_NUM; channelId++)
        {
                if (PolicerID == trtcmChannel[channelId])
                        return channelId;
        }

        /* if the id is not using channel, then select an avaible channel for Trtcm*/
        for (channelId = TRTCM_CHAN_NUM_FOR_GEMPORT; channelId < CONST_SHAPING_NUM; channelId++)
        {
                if (INVALID_POLICERID == trtcmChannel[channelId])
                        break;
        }

        return channelId;
}

static int setTrtcmChanUsedByUpStrmPolicer(uint16_t policerID, uint8_t chanID)
{
        if ( chanID <  TRTCM_CHAN_NUM_FOR_GEMPORT || \
             chanID >= CONST_SHAPING_NUM       || \
             INVALID_POLICERID == policerID){
                return -1;
        }

        trtcmChannel[chanID] = policerID;
        return 0;
}

static int setTrtcmAva4UpStrmPolicer(uint16_t policerID)
{
        uint8_t channelId = TRTCM_CHAN_NUM_FOR_GEMPORT;

        if (INVALID_POLICERID== policerID){
                return -1;
        }
        
        for (; channelId < CONST_SHAPING_NUM; ++ channelId){
                if (trtcmChannel[channelId] == policerID){
                        trtcmChannel[channelId] = INVALID_POLICERID;
                        break;
                }
        }
        if ( CONST_SHAPING_NUM == channelId ){
                return -1;
        }
        
        return 0;
}

int setVlanRxPolicerTableValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
    gpon_upstream_vlan_policer_ioctl_t ruleData;
    omci_alcatel_vlan_tag_up_policy_ptr vlanTagUp = NULL;
    char *tmp = NULL;
    uint8_t entryNum = 0;
    uint8_t actionType = 0;
    uint16_t vlanId = 0;
    uint32_t cir = 0;
    uint32_t cbs = 0;
    uint8_t chanID = 0;
    uint16_t policerID = 0;
    
    if(me_info==NULL || me_info->attributes == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] input paramter pointer is NULL\n",__FUNCTION__,__LINE__);
        return -1;
    }

    vlanTagUp = (omci_alcatel_vlan_tag_up_policy_ptr)me_info->attributes;

    tmp = vlanTagUp->vlanRxBehaviorTbl.buf;
    if(tmp == NULL)
	{
		omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] TABLE is NULL\n",__FUNCTION__,__LINE__);
		return -1;
	}

    entryNum = *tmp;
    vlanId = get16((uint8_t *)tmp+1);
    actionType = vlanId & 0x1;
    vlanId = vlanId >> 4;
    cir = get32((uint8_t *)tmp+3);
    cbs = get32((uint8_t *)tmp+7);
    if(entryNum > 8)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] entry num greater 8\n",__FUNCTION__,__LINE__);
		return -1;
    }

    policerID  = MAKE_VLAN_RX_POLICER_ID(me_info->inst_id, entryNum);
    chanID = getTrtcmChan4UpStrmPolicer(policerID);

    if( CONST_SHAPING_NUM == chanID ){
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d]No more hw resource for \"upstrm vlan tag policer\"!\n",__FUNCTION__,__LINE__);
        return -1;
    }
    memset(&ruleData, 0 , sizeof(ruleData));
    ruleData.ethID   = me_info->inst_id & 0xFF;
    ruleData.entryID = entryNum;
    ruleData.vid     = vlanId;
    ruleData.chanID  = chanID;
    omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d]cir = %d, sbs = %d\"!\n",__FUNCTION__,__LINE__,cir, cbs);
    if(actionType)
    {   
        setTrtcmChanUsedByUpStrmPolicer(policerID, chanID);
        addUpstreamVlanPolicer(&ruleData);
    }
    else
    {
        if (0 != setTrtcmAva4UpStrmPolicer(policerID))
        {
            omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] setTrtcmAva4UpStrmPolicer fail\n",__FUNCTION__,__LINE__);
            return -1;
        }

        delUpstreamVlanPolicer(&ruleData);
    }
    pon_clean_hwnat();
    return 0;
}
#endif
/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   GEMPort Protocol Monitoring History Data - Part 2

********************************************************************************************************************************/


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   ONT Optical Supervision Status

********************************************************************************************************************************/


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   ONT Generic V2

********************************************************************************************************************************/

int getEthernetPortToPortTrafficEnableIndicatorValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
    omci_alcatel_ont_generic_v2_ptr ontGeneric =NULL;
    uint8_t mask[MAX_ETH_PORT_NUM_ARRAY] = {0};
    if(me_info==NULL || me_info->attributes == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] input paramter pointer is NULL\n",__FUNCTION__,__LINE__);
        return -1;
    }

    ontGeneric = (omci_alcatel_ont_generic_v2_ptr)me_info->attributes;
    
    if(((macMT7530GetPortBrgInd(OMCI_MAC_BRIDGE_LAN_PORT1, &mask[0]) == 0)	&& ((mask[0] & MAX_OMCI_LAN_PORT_MASK)== MAX_OMCI_LAN_PORT_MASK))
		&& ((macMT7530GetPortBrgInd(OMCI_MAC_BRIDGE_LAN_PORT2, &mask[1]) == 0)	&& ((mask[1] & MAX_OMCI_LAN_PORT_MASK)== MAX_OMCI_LAN_PORT_MASK))
		&& ((macMT7530GetPortBrgInd(OMCI_MAC_BRIDGE_LAN_PORT3, &mask[2]) == 0)	&& ((mask[2] & MAX_OMCI_LAN_PORT_MASK)== MAX_OMCI_LAN_PORT_MASK))
		&& ((macMT7530GetPortBrgInd(OMCI_MAC_BRIDGE_LAN_PORT4, &mask[3]) == 0)	&& ((mask[3] & MAX_OMCI_LAN_PORT_MASK)== MAX_OMCI_LAN_PORT_MASK))){
		ontGeneric->ethPortTrafficInd = 1;
	}else{
		ontGeneric->ethPortTrafficInd = 0;
	}
    return 0;
}

int setEthernetPortToPortTrafficEnableIndicatorValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr)
{
	uint8_t mask[MAX_ETH_PORT_NUM_ARRAY] = {0};
	int i = 0;
    omci_alcatel_ont_generic_v2_ptr ontGeneric = NULL;
	int real_max_eth_port_num = MAX_ETH_PORT_NUM_ARRAY < MAX_ETH_PORT_NUM ?MAX_ETH_PORT_NUM_ARRAY:MAX_ETH_PORT_NUM;

    if(me_info==NULL || me_info->attributes == NULL)
    {
        omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] input paramter pointer is NULL\n",__FUNCTION__,__LINE__);
        return -1;
    }

    ontGeneric = (omci_alcatel_ont_generic_v2_ptr)me_info->attributes;
	if(omci_info_g.onuType != 2) //2--hgu modes
	{
    	switch(ontGeneric->ethPortTrafficInd){
    		case 0:
    			for(i = 0; i<real_max_eth_port_num; i++){
    				mask[i] = (OMCI_LAN_PORT1_OTHER_MASK | (1<<i));
    			}
    			break;
    		case 1:
    			for(i = 0; i<real_max_eth_port_num; i++){
    				mask[i] = MAX_OMCI_LAN_PORT_DEFAULT_MASK;
    			}
    			break;
    		default:
    		    omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] input paramter error\n",__FUNCTION__,__LINE__);
    			return -1;
    	
    	}

    	for(i = 0; i<real_max_eth_port_num; i++){
    		if(macMT7530SetPortBrgInd(i, mask[i]) != 0){
    			omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR, "[%s][%d] macMT7530SetPortBrgInd fail! port=%d,Ind=%d\n",__FUNCTION__,__LINE__,i, mask[i]);
    		}
    	}
	}
    return 0;
}

